<template>
  <div>
    <template v-if="$app.judgeData(orderInfo) && $app.judgeData(orLiInfo)">

      <Card class="marginB10">

        <!-- aTopType 1专利 2商标 3版权 -->
        <ATopBase :orderInfo="orderInfo" :orLiInfo="orLiInfo" :aTopType="1"/>

        <div class="overflowH " style="padding:0 40px;" >
          <template v-if="orderInfo.state == 0 || orderInfo.state==17 || orderInfo.state==18">
            <Steps :current="stateIng" class="marginB20">
              <Step title="创建订单"></Step>
              <Step :title="orderInfo.state_name"></Step>
            </Steps>
          </template>
          <template v-else>
            <Steps :current="stateIng" class="marginB20">
              <Step title="创建订单"></Step>
              <Step :title="'已付款'"></Step>
              <Step :title="'待缴申请费'"></Step>
              <Step :title="'审查中'"></Step>
              <Step :title="'已办理登记'"></Step>
              <Step :title="'已下证'"></Step>
            </Steps>
          </template>
          
          <OdUl :list="orderInfo.state_log" />
          
          
        </div>

        <div class="clearBoth " :class="(orderInfo.state==0 || orderInfo.state==1|| orderInfo.state==2)?' padding5 ' :' '"></div>

        
        <!-- 按钮优先处理 -->

        <!-- 0已取消,1未付款,2已付款，规则如下：0或1可以删除订单，1或2可以修改订单，1未支付，可以支付 -->
        <template v-if="orderInfo.state==0||orderInfo.state==1">
          <Button type="default" class="marginR10" @click="$app.delOrderOk(orLiInfo.id)">
            <Icon type="ios-trash" size="18" class="cCCC relative marginR5" />删 除
          </Button>
        </template>
        <template v-if="orderInfo.state==1||orderInfo.state==2">
          <Button type="primary" ghost class="marginR10" @click="ttW">
            <Icon type="ios-create-outline" size="18" class="relative marginR5" />修改订单
          </Button>
        </template>
        <!-- 未付款 -->
        <template v-if="orderInfo.state==1">
          <Button type="primary" class="marginR30" @click="zFu(parseInt(orderInfo.state))">
            <Icon type="logo-yen" size="14" class="relative marginR5"  />支 付
          </Button>
        </template>


      </Card>

      <template v-if="
        (orderInfo.state==5||orderInfo.state==14)&&
       $app.judgeData(orderInfo.note)
      ">
        <Card class="marginB20" >
          <!-- 5待缴申请费， 14待缴办理登记费，=》 专利订单里面另外有两次缴费操作 -->
          <span class="lineH34 c333 f_16 f_bold marginR20 relative" >系统预警</span>
          <Button type="primary" class="marginR30 relative" style="top:-2px;" @click="zFu(parseInt(orderInfo.state))">
            <Icon type="logo-yen" size="14" class="relative marginR5"  />
            {{pagText(parseInt(orderInfo.state))}}
          </Button>
          
          
          <!-- 缴申请费 -->
          <template v-if="orderInfo.state==5">
            请下载：
            <span class="marginR10 underline f_16 textLink cBlue" @click="$app.fileNameAgainDown($app.getVal_fileUrl(orderInfo.note.accept_note_path),orderInfo,orLiInfo)">
              受理通知书
            </span>
            <span class="marginR30 underline f_16 textLink cBlue" @click="$app.fileNameAgainDown($app.getVal_fileUrl(orderInfo.note.demand_note_path),orderInfo,orLiInfo)">
              缴费通知书
            </span>
            <span class="cRed f_16 marginR30">期限：{{orderInfo.note.demand_limit_date}}</span>
          </template>
          <!-- 缴办理登记费 -->
          <template v-if="orderInfo.state==14">
            请下载：
            <span class="marginR10 underline f_16 textLink cBlue" @click="$app.fileNameAgainDown($app.getVal_fileUrl(orderInfo.note.auth_note_path),orderInfo,orLiInfo)">
              授权通知书
            </span>
            <span class="marginR30 underline f_16 textLink cBlue" @click="$app.fileNameAgainDown($app.getVal_fileUrl(orderInfo.note.dealt_register_note_path),orderInfo,orLiInfo)">
              办理登记通知书
            </span>
            <span class="cRed f_16 marginR30">期限：{{orderInfo.note.dealt_register_limit_date}}</span>
          </template>
        </Card>
      </template>



      <His_list_pay :orderInfo="orderInfo" :orLiInfo="orLiInfo" />

      <template v-if="$app.judgeData(orderInfo.bz_list) || $app.judgeData(orderInfo.oa_list)">
        <Card class="marginB10">
          <Oa_list :orderInfo="orderInfo" :orLiInfo="orLiInfo" />
          <Bz_list :orderInfo="orderInfo" :orLiInfo="orLiInfo" />
        </Card>
      </template>

      <!-- 已下单未付款 -->
      <template v-if="orderInfo.state==1">
        <!-- 下单成功支付框 -->
        <PayBox ref="payBox" :noOrderList="true" />
      </template>
      
      <!-- 专利 5申请费 或 14办理登记费 支付框 -->
      <template v-if="orderInfo.state==5||orderInfo.state==14">
        <PayZL ref="PayZL" />
      </template>
      

    </template>
  </div>
</template>



<script>
import PayBox from "@$@/_service/payBox";//支付框 全局调用

// 专利详情页，内部各组件
import Bz_list from "./plugin/bz_list";
import Oa_list from "./plugin/oa_list";
import OdUl from "./plugin/odUl";
import PayZL from "./plugin/payZL";
import His_list_pay from "./plugin/his_list_pay";


// 专利缴年费
// import Temp from "@$@/_service/temp";

// 基础订单数据-当前进度
import ATopBase from "@$@/_orderInfo/aTop/aTopBase";



export default {
  name: "aTop",
  components: { 
    PayBox, 
    OdUl,
    Bz_list,
    Oa_list,
    PayZL,
    His_list_pay,
    ATopBase,
    // Temp 
  },
  props: ["orderInfo", "orLiInfo"],
  data() {
    let data = {
      stateIng: 0, //当前进度
    };
    let tool = {};
    return Object.assign(data, tool);
  },
  watch: {
    orderInfo(newVal, oldVal) {
      let { 
        state,
        note,
      } = newVal;

      
      

      switch (parseInt(state)) {
        case 0:
          this.stateIng = 1;
          break;
        case 1:
          this.stateIng = 0;
          break;
        case 2:
        case 3:
        case 4:
          this.stateIng = 1;
          break;
        case 5:
          this.stateIng = 2;
          break;
        case 6:
        case 7:
        case 8:
        case 9:
        case 10:
        case 11:
        case 12:
        case 13:
        case 14:
          this.stateIng = 3;
          break;
        case 15:
          this.stateIng = 4;
          break;
        case 16:
          this.stateIng = 5;
          break;
        case 17:
        case 18:
          this.stateIng = 1;
          break;
      }
    }
  },
  mounted() {
  },
  methods: {
    ttW() {
      $app.goEdit(this);//跳转编辑
    },
    pagText(state) {
      let out = "";
      switch (state) {
        case 5:
          out = "缴纳申请费";
          break;
        case 14:
          out = "缴纳办理登记费";
          break;
      }
      return out;
    },
    zFu(state) {
      let {
        $route: {
          query: { order_id }
        }
      } = this;
      if (state == 1) {//第一次支付
        $app.payBoxShow(this, order_id,{
          payFun:() => {
            this.$parent.getData();//调用父亲初始化数据方法
          }
        });

        
      } else if (state == 5 || state == 14) {//申请费 办理登记费
        this.$refs['PayZL'].payBox=true;
        this.$refs['PayZL'].orderInfo=this.orderInfo;
      }
    },

    // 专利缴年费
    nianF_Z(){
      let num=this.orderInfo.patent_number;
      this.$refs['Temp'].show119Box(num,true);
    }

    
  }
};
</script>

